hvmloader: Correct bug in low mmio region accounting
authorGeorge Dunlap <george.dunlap@eu.citrix.com>
Tue, 18 Jun 2013 14:11:03 +0000 (15:11 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 24 Jun 2013 11:20:29 +0000 (12:20 +0100)
commit703e150231e26079d72ecca76701a825e7b9b927
tree3419aa781db8f4cce31348a16da2a979acefae52
parent3458ab670f3043100f2c0ae5634c44226eb3d2ca
hvmloader: Correct bug in low mmio region accounting

When deciding whether to map a device in low MMIO space (<4GiB),
hvmloader compares it with "mmio_left", which is set to the size of
the low MMIO range (pci_mem_end - pci_mem_start).  However, even if it
does map a device in high MMIO space, it still removes the size of its
BAR from mmio_left.

In reality we don't need to do a separate accounting of the low memory
available -- this can be calculated from mem_resource.  Just get rid
of the variable and the duplicate accounting entirely.  This will make
the code more robust.

Note also that the calculation of whether to move a device to 64-bit
is fragile at the moment, depending on some unstated assumptions.
State those assumptions in a comment for future reference.

v5:
 - Add comment documenting fragility of the move-to-highmem check
v3:
 - Use mem_resource values directly instead of doing duplicate
   accounting

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Stefano Stabellini <stefano.stabellini@citrix.com>
CC: Hanweidong <hanweidong@huawei.com>
CC: Keir Fraser <keir@xen.org>
tools/firmware/hvmloader/pci.c